package holdObject;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class ListInteration {

	public static void main(String[] args) {
		List<String> pets = new ArrayList<>();
		pets.add("Rat");
		pets.add("Manx");
		pets.add("Cymric");
		pets.add("Mutt");
		pets.add("Pug");
		pets.add("Cymric");
		pets.add("Manx");
		pets.add("Cymric");
		pets.add("Rat");
		pets.add("EgyptianMau");
		
		ListIterator<String> listIterator = pets.listIterator();
		
		while (listIterator.hasNext()) {
			System.out.println(listIterator.next()+","
		+listIterator.nextIndex()+","+listIterator.previousIndex());
		}
		
		System.out.println();
		
		while(listIterator.hasPrevious()){
			System.out.println(listIterator.previous()+","+listIterator.previousIndex());
		}
	}

}
